//
//  WaringView.swift
//  Box
//
//  Created by mn on 2025/4/3.
//
import UIKit
import SnapKit

class WaringView: UIView {
    
    private let imageView: UIImageView = {
        let imageView = UIImageView(image: UIImage.waring)
        imageView.contentMode = .scaleAspectFit
        return imageView
    }()
    
    private let warningLabel1: UILabel = {
        let label = UILabel()
        label.text = "注销后所有数据及资产将清空且账户无法登录"
        label.textAlignment = .center
        label.textColor = .fromHex("#FF5858")
        label.font = UIFont.systemFont(ofSize: 18, weight: .heavy)
        label.numberOfLines = 0
        return label
    }()
    
    private let warningLabel2: UILabel = {
        let label = UILabel()
        label.text = "重新注册将按新用户处理"
        label.textAlignment = .center
        label.textColor = .fromHex("#BCBCBC")
        label.font = UIFont.systemFont(ofSize: 15)
        return label
    }()
    lazy var button: InsetBorderButton = {
        let button = InsetBorderButton(type: .custom)
        button.setTitle("确认注销", for: .normal)
        button.setTitleColor(.white, for: .normal)
        button.layer.cornerRadius = 7.5
        button.titleLabel?.font = .systemFont(ofSize: 16)
        button.backgroundColor = .fromHex("#FF5858")
        button.borderColor = .black
        return button
    }()
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupView()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setupView()
    }
    
    private func setupView() {
        layer.cornerRadius = 32
        layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
        backgroundColor = .black
        addSubview(imageView)
        addSubview(warningLabel1)
        addSubview(warningLabel2)
        addSubview(button)
        imageView.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(30)
            make.centerX.equalToSuperview()
            make.width.height.equalTo(108)
        }
        
        warningLabel1.snp.makeConstraints { make in
            make.top.equalTo(imageView.snp.bottom).offset(4.5)
            make.left.right.equalToSuperview().inset(60)
        }
        
        warningLabel2.snp.makeConstraints { make in
            make.top.equalTo(warningLabel1.snp.bottom).offset(12)
            make.left.right.equalToSuperview().inset(60)
        }
        button.snp.makeConstraints { make in
            make.top.equalTo(warningLabel2.snp.bottom).offset(74)
            make.left.right.equalToSuperview().inset(44)
            make.height.equalTo(48)
            make.bottom.equalTo(safeAreaLayoutGuide.snp.bottom).offset(-25)
        }
    }

}
